package org.jeecg.modules.cascv.image.tools;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.HexUtil;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;

/**
 * @author;作者
 * @Date 2023/5/12 13:58
 * @Description :
 * @Version
 */
public class FuguiUDP {
    public static void main(String[] args) throws Exception {
        byte[] bytes = FileUtil.readBytes("E:\\11图像数据\\cut2\\高精度\\" +
                "T20221101005256_0001_0071_F1_00_6DCD_2024_0071_71_6D9D_000000000.dat");
        String s = HexUtil.encodeHexStr(bytes);
        String[] split = s.split("55aa");
        JSONObject jsonObject = new JSONObject();

        for (String s1 : split) {
            if (StringUtils.isEmpty(s1)) {
                continue;
            }

            String data = "55aa" + s1;
            Long second = Long.parseUnsignedLong(data.substring(16, 22), 16);

            Long subSecond = Long.parseUnsignedLong(data.substring(22, 26), 16);
            String substring = data.substring(32, data.length() - 4);
            jsonObject.put("tableName", "6D9DH_71H");
            jsonObject.put("APED_APDATA_0_2005_1", substring);
            jsonObject.put("second", second);
            jsonObject.put("subsecond", subSecond);
            FileUtil.appendUtf8String(jsonObject.toString() + System.lineSeparator(),
                    "E:\\11图像数据\\cut2\\高精度\\" +
                            "6D9DH_71H.txt");
        }
    }
}
